package com.cheung.leetcode.contest.week.week406;

import  org.junit.jupiter.api.Test;

/**
 * @BelongsProject : java-leetcode
 * @BelongsPackage : com.cheung.leetcode.contest.week406
 * @Author :  cheungming
 * @CreateTime : 2024-07-14 10:33:06
 * @Description : 竞赛100352
 * @Version : 1.0
 */
public class Code100352Test {

    public String getSmallestString(String s) {
        char[] charArray = s.toCharArray();
        for (int i = 1; i < charArray.length; i++) {
            char c = charArray[i - 1];
            char d = charArray[i];
            if (c > d && (c - d) % 2 == 0) {
                charArray[i - 1] = d;
                charArray[i] = c;
                break;
            }
        }
        return new String(charArray);
    }

    @Test
    public void test1() {
        assert "43520".equals(getSmallestString("45320"));
    }

    @Test
    public void test2() {
        assert "001".equals(getSmallestString("001"));
    }
}
